﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RBOSS.Business.InternalUser;

namespace RBOSS.WebUI
{
    public partial class InternalUserApproval : System.Web.UI.Page
    {
        Productapproval pro = new Productapproval();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["prod"] != null)
            {
                GridView1.DataSource = pro.getproducts();
            }
            else
                GridView1.DataSource = pro.getallproducts();
            GridView1.DataBind();

        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            gvbind();
        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
            gvbind();
        }


        protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            GridView1.EditIndex = -1;
            gvbind();
        }

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int productid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
            GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
            CheckBox ckbx = (CheckBox)row.Cells[6].Controls[0];
            pro.updateIsProductEnabled(productid, !ckbx.Checked);
           // pro.updateIsProductEnabled(productid, true);

            GridView1.EditIndex = -1;
            gvbind();
        }
        protected void gvbind()
        {
            if (Request.QueryString["prod"] != null)
            {
                GridView1.DataSource = pro.getproducts();
            }
            else
                GridView1.DataSource = pro.getallproducts();
            GridView1.DataBind();

        }     
    }
}